package org.deltaset.meta.internal.testdomain;

import java.util.Collection;
import org.deltaset.meta.annotation.DsLabel;

/**
 *
 * @author dmakariev
 */
public abstract class AbstractParent<P extends AbstractParent, T extends AbstractChild> extends CollectionBaseEntity{
       
    private String parentName;
    
    abstract Collection<T> getChildren();
    protected abstract T newChild(@DsLabel("Child name(abs)") String childName);
    protected abstract P addNumberOfChildren(@DsLabel("Number of children(abs)") int numberOfChildren);
    
    public P addChildren( int numberOfChildren){
        for (int i = 0; i < numberOfChildren; i++) {
            final String childName = getParentName()+ " child "+i;
            final T child = newChild(childName);
            getChildren().add(child);            
        }
        return (P) this;
    }        

    public String getParentName() {
        return parentName;
    }

    public void setParentName(String parentName) {
        this.parentName = parentName;
    }
    
    public String title(){
        return parentName;
    }
    
}
